package com.huiquan.foundation.service;

import java.util.Date;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.huiquan.analysis.dao.UserDao;
import com.huiquan.analysis.domain.User;
import com.huiquan.foundation.dao.UserRecordDao;
import com.huiquan.foundation.domain.UserRecord;
import com.huiquan.framework.base.BaseService;

@Service
public class UserRecordService extends BaseService {
	
	
	@Autowired
	private UserDao userDao;
	@Autowired
	private UserRecordDao userRecordDao;	
	public void addUpUserRecord(long uid,long count){
		User user = userDao.retrieveObjectById((int)uid);
		if(user != null && user.getRole() != 1){
			UserRecord value = new UserRecord();
			if(count >0){
				value.setCount(count);
			}else{
				value.setCount(0L);
			}
			value.setRole((long)user.getRole());
			value.setUid(user.getUserId());
			userRecordDao.insert(value);
		}
	}
	
	
	
	public Long getCountByDate(long uid,Date date){
		return userRecordDao.retrieveCountByDateRoleUid( uid, date);
	}
	
	
	
	
}
